Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(watch): support watching external files #13087

Merged
merged 9 commits into from
Dec 15, 2021
Merged

feat(watch): support watching external files #13087

merged 9 commits into from
Dec 15, 2021

Conversation

jespertheend
Copy link
Contributor

Fixes: #12197

cli/flags.rs Outdated Show resolved Hide resolved
cli/flags.rs Outdated Show resolved Hide resolved
write(&external_file_to_watch, "Hello world2").unwrap();

assert_contains!(stderr_lines.next().unwrap(), "Restarting");
wait_for("Process finished", &mut stderr_lines);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to see what happens with the test if watching doesn't work correctly, it seems like the test will hang forever in this case. Not sure if this is an issue.

@jespertheend jespertheend marked this pull request as ready for review December 15, 2021 00:09
cli/flags.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @jespertheend! I have only a single nitpick for the help text, but other than that it looks good to me. I will let David review it as well before landing.

jespertheend and others added 2 commits December 15, 2021 01:27
Co-authored-by: Bartek Iwańczuk <[email protected]>
@jespertheend
Copy link
Contributor Author

Thanks for the review! I didn't really like my wording for the help message tbh, but couldn't think of anything better.
Your version seems much better!

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jespertheend! Looks good overall, but I think we just need to change watch_arg() to not take files for subcommands that don't support it.

cli/flags.rs Outdated Show resolved Hide resolved
Comment on lines +2433 to +2434
if let Some(f) = matches.values_of("watch") {
flags.watch = Some(f.map(PathBuf::from).collect());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this still work with deno run --watch? Is there a unit test that covers this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I see no unit test that covers deno run --watch=file1,file2, could you add it @jespertheend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should cover deno run --watch. But now that I think about it, it seems like this shouldn't work. I'll investigate.
I'll also add the extra test 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this works because matches.values_of returns an empty vec when used as --watch without any files.
I've added the extra unit test.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jespertheend!

@dsherret dsherret merged commit 5a3ded6 into denoland:main Dec 15, 2021
@jespertheend jespertheend deleted the watching-external-files branch December 20, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request - Allow watching files outside of the module graph
3 participants